<script setup>
  import { ref } from 'vue'
  import { DeleteOutlined } from '@ant-design/icons-vue'
  import InputNumber from "@/components/InputNumber.vue";
  const props = defineProps(['goods'])
  const isC = ref(false)
  const tapCheck = () => {
    isC.value = !isC.value
  }
</script>

<template>
  <div class="goods-item">
    <i class="check" :class="isC?'fa-solid fa-circle-check':'fa-regular fa-circle'" @click="tapCheck"></i>
    <div class="box">
      <img :src="goods?.thumb_url" alt="" class="goods-img"/>
      <div class="goods-info">
        <div class="goods-name"> {{ goods.goods_name }} </div>
        <div class="goods-spec ellipsis"> 规格： {{ goods?.spece_value_title?goods?.spece_value_title:'默认规格' }} </div>
        <div class="actions">
          <DeleteOutlined />
        </div>
      </div>
    </div>
    <div class="box mt">
      <InputNumber :number="goods?.num" :sku="goods?.sku" class="change-num"/>
      <div class="goods-price">
        <div class="new-price fh">  {{ goods.price }} </div>
        <div class="old-price fh">  {{ goods.original_price }} </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
  .goods-item {
    gap: 20px;
    display: flex;
    align-items: start;
    padding-left: 30px;
    position: relative;
    .check {
      cursor: pointer;
      font-size: 16px;
      color: var(--primary);
      position: absolute;
      top: 50%;
      left: 0;
      transform: translateY(-50%);
    }
    .box {
      display: flex;
      align-items: start;
      gap: 20px;
    }
    .goods-img {
      width: 100px;
      height: 130px;
      border-radius: 10px;
    }
    .goods-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 5px;
      .ellipsis {
        max-width: 470px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .goods-name {
        max-width: 470px;
        font-size: 16px;
        font-weight: bold;
      }
      .goods-spec, .shop-name {
        color: #999;
      }
      .actions {
        margin-top: 10px;
        .anticon {
          color: #999;
          font-size: 20px;
          cursor: pointer;
          margin-right: 10px;
          &:hover {
            color: var(--primary);
          }
        }
      }
    }
    //.change-num {
    //  position: absolute;
    //  top: 0;
    //  right: 0;
    //}
    .goods-price {
      color: #999;
      font-size: 14px;
      font-weight: bold;
      display: flex;
      align-items: center;
      gap: 10px;
      .new-price, .old-price {
        white-space: nowrap;
      }
      .new-price {
        color: #f44;
        font-size: 18px;
      }
      .old-price {
        text-decoration: line-through;
      }
    }
  }

  @media (max-width: 750px) {
    .goods-item {
      display: block;
    }
    .mt {
      margin-top: 20px;
      justify-content: space-between;
    }
    .goods-name, .ellipsis {
      max-width: 100%;
    }
  }
</style>